import { $post, $get } from '@/api/request'
const workUrl = '/workorder'

// 工单列表
// 查询工单记录
export function getWorkOrderList (data) {
  return $get({
    url: `${workUrl}/work/order/manage/list`,
    data
  })
}

// 获取工单详情
export function getWorkOrderDetail (no) {
  return $get({
    url: `${workUrl}/work/order/manage/detail/` + no
  })
}

// 获取所有角色列表
export function getAllRoleList (data) {
  return $get({
    url: `${workUrl}/work/order/manage/getAllRoleList`,
    data
  })
}

// 获取角色下用户列表
// 根据角色编号获取角色用户列表
export const getListByRoleNoList = roleNo => {
  return $get({
    url: `${workUrl}/work/order/manage/getAllUser/` + roleNo
  })
}

// 派单
export function workOrderDistribute (data) {
  return $post({
    url: `${workUrl}/work/order/manage/distribute`,
    data
  })
}

// 消单
export const cancelWorkOrder = no => {
  return $get({
    url: `${workUrl}/work/order/manage/cancel/` + no
  })
}

// 工单类型
// 添加工单类型
export const addWorkOrderType = data => {
  return $post({
    url: `${workUrl}/wkTypeInfo/add`,
    data
  })
}

// 修改工单类型
export const updateWorkOrderType = data => {
  return $post({
    url: `${workUrl}/wkTypeInfo/update`,
    data
  })
}

// 删除工单类型
export const deleteWorkOrder = typeNo => {
  return $get({
    url: `${workUrl}/wkTypeInfo/delete/` + typeNo
  })
}

// 分页查询工单类型列表
export const getWorkOrderTypeList = data => {
  return $get({
    url: `${workUrl}/wkTypeInfo/getPage`,
    data
  })
}

// 查询工单类型关联的应用场景数
export const getRelationList = typeNo => {
  return $get({
    url: `${workUrl}/wkTypeInfo/wkRelation/` + typeNo
  })
}

// 查询工单类型列表
export const getTypeList = tenantNo => {
  return $get({
    url: `${workUrl}/wkTypeInfo/wkTypeList/` + tenantNo
  })
}

// 近七天数量统计
export function numCount (data) {
  return $get({
    url: `${workUrl}/work/order/dashboard/numCount`,
    data
  })
}

// 工单状态统计
export function statusCount (data) {
  return $get({
    url: `${workUrl}/work/order/dashboard/statusCount`,
    data
  })
}

// tendency
export function tendency (data) {
  return $get({
    url: `${workUrl}/work/order/dashboard/tendency/${data}`
  })
}
